//头部弹出广告
var popUp_top = document.querySelector('.popUp_top');
var popUp_top_1 = popUp_top.querySelector('.popUp_top_1');
var popUp_top_1Img = popUp_top_1.querySelector('.popUp_top_1 img')
var popUp_top_2 = popUp_top.querySelector('.popUp_top_2');
var popUp_top_2Img = popUp_top.querySelector('.popUp_top_2 img');
var header = document.querySelector('.header');
popUp_top.addEventListener('mouseenter', function () {
    popUp_top_1.style.transform = 'translateY(0px)';
    popUp_top_1Img.style.transform = 'translateY(0px)';
    popUp_top.style.height = '250px';
    popUp_top_2.style.transform = 'translateY(0px)';
    popUp_top_2Img.style.transform = 'translateY(0px)';
})
popUp_top.addEventListener('mouseleave', function () {
    popUp_top_1.style.transform = 'translateY(-125px)';
    popUp_top_1Img.style.transform = 'translateY(-125px)';
    popUp_top.style.height = '80px';
})
// 关闭头部弹出广告
var shut_top = popUp_top.querySelector('.shut_top');
shut_top.addEventListener('click', function () {
    popUp_top.style.display = 'none';
})


//关闭中心弹出广告
var advertising_center = document.querySelector('.advertising_center');
var shut_center = advertising_center.querySelector('.shut_center');
shut_center.addEventListener('click', function () {
    advertising_center.style.display = 'none';
})

// 右侧固定栏
// 返回顶部
window.onload = function () {
    var returnTop = document.querySelector('.returnTop');
    returnTop.addEventListener('click', function () {
        var time = setInterval(function () {
            //获取滚动条高度
            var osTop = document.documentElement.scrollTop || document.body.scrollTop;
            // 设置速度差，
            var speed = Math.floor(-osTop / 10);
            document.documentElement.scrollTop = document.body.scrollTop = osTop + speed;
            isTop = true;
            if (osTop == 0) {
                clearInterval(time);
            }
        }, 30)
    })
}

//头部客户服务下拉菜单
var kehuFw = document.querySelector('.kehuFw');
var div2 = kehuFw.querySelector('div:nth-child(2)');
var div3 = kehuFw.querySelector('div:nth-child(3)');
var divI = kehuFw.querySelector('div:nth-child(1)>a>i');

kehuFw.style.borderLeft = '1px solid #f4f4f4';
kehuFw.style.borderRight = '1px solid #f4f4f4';

kehuFw.addEventListener('mouseenter', function () {
    div2.style.display = 'block';
    div3.style.display = 'block';
    kehuFw.style.background = '#fff';
    kehuFw.style.border = '1px solid #e5e5e5';
    kehuFw.style.borderTop = 'none';
    divI.style.transform = 'rotate(' + 180 + 'deg)';
    divI.style.display = 'inline-block';

})
kehuFw.addEventListener('mouseleave', function () {
    div2.style.display = 'none';
    div3.style.display = 'none';
    kehuFw.style.background = '#f4f4f4';
    kehuFw.style.borderLeft = '1px solid #f4f4f4';
    kehuFw.style.borderRight = '1px solid #f4f4f4';
    kehuFw.style.borderBottom = 'none';
    divI.style.transform = 'rotate(' + 0 + 'deg)';
    divI.style.display = 'inline-block';
})

// 轮播
var kv = document.querySelector('.kv');
var warp = kv.querySelector('.warp');
var oli = warp.querySelectorAll('li');
var next = document.querySelector('.next');
var pre = document.querySelector('.pre');
var conner= 0;
function showImg(index) {
    for(var i=0;i<oli.length;i++){
        oli[i].style.opacity='0';
    }
    oli[index].style.opacity='1';
}
pre.addEventListener('click',function(){
    conner--;
    showImg(conner);
})
next.addEventListener('click',function(){
    conner++;
    showImg(conner);
    console.log(conner);
    
})

// 轮播左导航弹出
var hd_more_allsort = document.querySelector('.hd_more_allsort');
var ali = hd_more_allsort.querySelectorAll('.hd_more_allsort>li');
// 弹出导航商品
for (var i = 0; i < ali.length; i++) {
    (function (item) {
        ali[item].addEventListener('mouseenter', function () {
            ali[item].children[1].style.display = 'block';
            ali[item].style.background = '#fff';
        })
        ali[item].addEventListener('mouseleave', function () {
            ali[item].children[1].style.display = 'none';
            ali[item].style.background = '#444';
        })
    })(i)

}